package WaterandJugProblem;

public class Solution {
    public boolean canMeasureWater(int x, int y, int z) {
        if (x+y<z) return false;
        if (z==0) return true;
        if (gcd(x,y)==1){
        	return (z<=x+y?true:false);
        }
        else
        return (z%(x-y)==0?true:false);
    }

	private int gcd(int x, int y) {
		if (y==0) return x;
		return gcd(y,x%y);
	}
}
